#ifndef __ALTAIR_SYSTEM_APM_H__
#define __ALTAIR_SYSTEM_APM_H__

#include <types.h>

/**
 *  APM_Installed()
 *  vrati verzi APM v hexa tvaru 0xHHLL (HH.LL)
 */
int APM_Installed() {
  int result;
  int r_bp;

  asm push bp;
  asm pop r_bp;

  asm mov ax, 0x40;
  asm mov bx, r_bp;
  asm int OSINT;

  return result;
}

/**
 *  APM_PowerOff()
 *  pokusi se vypnout pocitac pres APM
 */
int APM_PowerOff() {
  int result;
  int r_bp;

  asm push bp;
  asm pop r_bp;

  asm mov ax, 0x41;
  asm mov bx, r_bp;
  asm int OSINT;

  return result;
}

/**
 *  APM_Reboot()
 *  restartuje pocitac (APM neni zapotrebi)
 */
void APM_Reboot() {
  int temp;
  do {
    temp = __inportb__(0x64);
    if (temp & 1)
      __inportb__(0x60);
  } while (temp & 2);
  __outportb__(0x64, 0xFE);

  return;
}

#endif
